package com.security.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.security.valid.MyConstraint;
import lombok.*;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Past;
import java.util.Date;

/**
 * ${DESCRIPTION}
 *
 * @author roger
 * @email 190642964@qq.com
 * @create 2017-11-01 10:58
 **/
@Setter
@ToString
@NoArgsConstructor
public class User {

    public User(Long id, String name, String password) {
        this.id = id;
        this.name = name;
        this.password = password;
    }

    public User(Long id, String name, String password, Date birthday) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.birthday = birthday;
    }

    public interface UserSimpleView {
    }

    public interface UserDetailView extends UserSimpleView {
    }

    @JsonView(UserSimpleView.class)
    @Getter
    private Long id;

    @MyConstraint(message = "这是一个测试")
    private String name;

    @NotBlank(message = "password 不能为空")
    private String password;

    @Past(message = "生日必须是一个过去的时间")
    @JsonView(UserSimpleView.class)
    @Getter
    private Date birthday;

    @JsonView(UserSimpleView.class)
    public String getName() {
        return name;
    }

    @JsonView(UserDetailView.class)
    public String getPassword() {
        return password;
    }
}
